package ai.yue.open.service.cd.controller;

import ai.yue.library.base.annotation.ApiVersion;
import ai.yue.library.base.ipo.ValidationGroups;
import ai.yue.library.base.view.Result;
import ai.yue.open.service.cd.ipo.ConfNotifyIPO;
import ai.yue.open.service.cd.service.ConfNotifyService;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@ApiVersion
@AllArgsConstructor
@RestController
@RequestMapping("/auth/{version}/confNotify")
public class ConfNotifyController {

    ConfNotifyService confNotifyService;

    @PostMapping("/insert")
    public Result<?> insert(ConfNotifyIPO confNotifyIPO) {
        return confNotifyService.insert(confNotifyIPO);
    }

    @DeleteMapping("/deleteById")
    public Result<?> deleteById(Long id) {
        return confNotifyService.deleteById(id);
    }

    @DeleteMapping("/deleteByIds")
    public Result<?> deleteByIds(List<Long> ids) {
        return confNotifyService.deleteByIds(ids);
    }

    @PutMapping("/updateById")
    public Result<?> updateById(@Validated(ValidationGroups.Update.class) ConfNotifyIPO confNotifyIPO) {
        return confNotifyService.updateById(confNotifyIPO);
    }

    @GetMapping("/page")
    public Result<?> page() {
        // 前端需要传规范的分页参数，框架会自动从request中获取
        return confNotifyService.page();
    }

    @GetMapping("/listAll")
    public Result<?> listAll() {
        return confNotifyService.listAll();
    }

}
